local mouli = fk.CreateSkill{
    name = "tyta__mouli",
}

mouli:addEffect("viewas",{
  anim_type = "special",
  pattern = ".",
  prompt = "#tyheg__mibei-prompt",
  interaction = function(self, player)
    local cids = table.filter(player:getCardIds("h"), function(id)
      return Fk:getCardById(id):getMark("@@mibei_cardMark-inhand-turn") ~= 0 and (Fk:getCardById(id):isCommonTrick() or Fk:getCardById(id).type == Card.TypeBasic)
    end)
    local cards  = table.map(cids, function(id)
      return Fk:getCardById(id).name
    end)
    if #cards == 0 then return end
    return UI.CardNameBox {choices = cards}
  end,
  card_filter = function(self, player, to_select, selected)
    if self.interaction.data == nil then return end
    return #selected == 0 and Fk:getCardById(to_select):getMark("@@mibei_cardMark-inhand-turn") ~= 0
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcard(cards[1])
    card.skillName = mouli.name
    return card
  end,
  enabled_at_play = function(self, player)
    return table.find(player:getCardIds("h"), function(id)
      return Fk:getCardById(id):getMark("@@mibei_cardMark-inhand-turn") ~= 0
    end) and player:usedSkillTimes(mouli.name, Player.HistoryPhase) == 0 and player.phase ~= Player.NotActive
  end,
  enabled_at_response = function(self, player, response)
    return not response and table.find(player:getCardIds("h"), function(id)
      return Fk:getCardById(id):getMark("@@mibei_cardMark-inhand-turn") ~= 0
    end) and player:usedSkillTimes(mouli.name, Player.HistoryPhase) == 0 and player.phase ~= Player.NotActive
  end,
})

Fk:loadTranslationTable{
    ["tyta__mouli"] = "谋立",
    [":tyta__mouli"] = "出牌阶段限一次，你可将一张“秘备”牌当其中一张基本牌或普通锦囊牌使用。(【挟天子以令诸侯】除外)",

    ["$tyta__mouli1"] = "司马氏虽权尊势重，吾等徐图亦无不可！",
    ["$tyta__mouli2"] = "先谋后事者昌，先事后谋者亡！",
}

return mouli